package seqlist.oj;

/**
 * @Author: yuisama
 * @Date: 2019/12/11 11:44
 * @Description:环形链表-快慢指针
 * https://leetcode-cn.com/problems/linked-list-cycle/
 */
public class Solution141 {
    public boolean hasCycle(ListNode head) {
        if (head == null|| head.next == null) {
            return false;
        }
        ListNode low = head;
        ListNode fast = head;
        while (fast != null && fast.next != null) {
            low = low.next;
            fast = fast.next.next;
            if (low == fast) {
                return true;
            }
        }
        return false;
    }
}
